package com.scholarship.modules.student.controller;

import com.scholarship.common.entity.RetCode;
import com.scholarship.common.entity.RetResponse;
import com.scholarship.common.entity.RetResult;
import com.scholarship.modules.student.dto.MajorInfoDto;
import com.scholarship.modules.student.dto.StudentChangeInfoDto;
import com.scholarship.modules.student.dto.StudentInfoDto;
import com.scholarship.modules.student.dto.StudentPasswordDto;
import com.scholarship.modules.student.dto.applicationDto.*;
import com.scholarship.modules.student.service.StuApplicationService;
import com.scholarship.modules.student.service.StudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
    @author： HuangHao
    @date： 2021/3/2 16:46
    @description： 学生端controller
    @modifiedBy：
*/

@Api(tags = {"学生端控制层"})
@RestController
public class StudentController {
    @Autowired
    private StudentService studentService;
    @Autowired
    private StuApplicationService stuApplicationService;

    //学生首次登入修改密码
    @PostMapping("/student/firstLogin")
    public RetResult firstLogin(@RequestParam("userId") String userId, @RequestParam("password") String password) throws Exception{
//        int ret = studentService.updateStudentPwdWhenFirstLogin(userId, password);
//        if (ret != 1) {
//            return RetResponse.makeRsp(RetCode.FAIL, "第一次登入修改密码失败");
//        }
//        return RetResponse.makeRsp(RetCode.SUCCESS, "修改密码成功");
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
    * 返回学生的基本个人信息（登录后首页信息）
    * userId : String 用户Id
    */
    @ApiOperation("获取学生基本个人信息")
    @PostMapping("/student/getStudentBaseInfo")
    public RetResult getStudentBaseInfo(@RequestParam("userId") String userId) {
//        StudentInfoDto studentInfo = studentService.getStudentInfo(userId);
//        if (studentInfo == null)
//            return RetResponse.makeRsp(RetCode.FAIL ,"userId出错或该用户数据为空", null);
//        return RetResponse.makeRsp(200, "学生基本信息", studentInfo);
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
    * 获取学生专业信息
    * userId : String 用户Id
    */
    @ApiOperation("获取学生专业信息")
    @PostMapping("/student/getStudentMajorInfo")
    public RetResult getStudentMajorInfo(@RequestParam("userId") String userId) {
//        MajorInfoDto majorInfoDto = studentService.getStudentMajorInfo(userId);
//        if (majorInfoDto == null)
//            return RetResponse.makeErrRsp("userId出错");
//        return RetResponse.makeRsp(200, "学生专业信息", majorInfoDto);
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
     * 学生修改密码
     * user_id : String 用户id
     * original_password : String 原密码
     * new_assword : String 新密码
     */
    @ApiOperation("修改学生密码")
    @PostMapping("/student/studentChangePassword")
    public RetResult studentChangePassword(@RequestBody StudentPasswordDto studentPassword) throws Exception{
//        int ret = studentService.updateStudentPasswordInfo(studentPassword);
//        if (ret == 0) {
//            return RetResponse.makeErrRsp("更新密码出错，原密码不正确");
//        }
//        else if(ret == 1) {
//            return RetResponse.makeErrRsp("更新密码出错，请稍后再试");
//        }
//        return RetResponse.makeOKRsp();
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
     * 学生修改基本信息
     */
    @ApiOperation("修改学生基本信息")
    @PostMapping("/student/studentChangeInfo")
    public RetResult studentChangeInfo(@RequestBody StudentChangeInfoDto stuInfo) {
//        int res = studentService.updateStudentBaseInfo(stuInfo);
//        if (res == 0)
//            return RetResponse.makeErrRsp("更新学生基本信息出错，请重试");
//        return RetResponse.makeOKRsp();
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
    * 奖学金申请基本信息
    */
    @ApiOperation("奖学金申请基本信息")
    @PostMapping("/student/getApplicationBaseInfo")
    public RetResult getApplicationBaseInfo(@RequestParam("userId") String userId) {
        ApplicationBaseInfoDto res = studentService.getApplicationBaseInfo(userId);
        return RetResponse.makeRsp(RetCode.SUCCESS, "成功", res);
    }

    /*
    * 奖学金申请接收——外语成绩
    */
    @ApiOperation("奖学金申请接收——外语成绩")
    @PostMapping("/student/receiveForeignApplication")
    public RetResult receiveForeignApplication(@RequestBody ForeignExamDto foreignExamInfo) {
//        if (foreignExamInfo.getCET4() == null || foreignExamInfo.getCET4() == null)
//            return RetResponse.makeRsp(RetCode.FAIL, "四六级成绩为空");
//
//        int ret = stuApplicationService.insertForeignExam(foreignExamInfo);
//        if (ret == 0)
//            return RetResponse.makeErrRsp("error");
//
//        if (foreignExamInfo.getExamName() == null || foreignExamInfo.getExamTime() == null || foreignExamInfo.getExamScore() == null)
//            return  RetResponse.makeRsp(RetCode.SUCCESS, "插入外语成绩成功，但存在某个字段为空值");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "");
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
    * 奖学金申请接收——专业证书
    */
    @ApiOperation("奖学金申请接收——专业证书")
    @PostMapping("/student/receiveMajorExamApplication")
    public RetResult receiveMajorExamApplication(@RequestBody MajorExamDto majorExamDto) {
//        int ret = stuApplicationService.insertMajorExam(majorExamDto);
//        if (ret == 0)
//            return RetResponse.makeErrRsp("error");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "");
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
    * 奖学金申请接收——专业竞赛加分和IT加分
    * 以后可考虑二者合并
    */
    @ApiOperation("奖学金申请接收——专业竞赛加分")
    @PostMapping("/student/receiveMajorCompetitionApplication")
    public RetResult receiveMajorCompetitionApplication(@RequestBody MajorCompetitionDto majorCompetitionDto) {
//        int ret = stuApplicationService.insertMajorCompetition(majorCompetitionDto);
//        if (ret == 0)
//            return RetResponse.makeErrRsp("error");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "");
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }
    @ApiOperation("奖学金申请接收——IT节加分")
    @PostMapping("/student/receiveITCompetitionApplication")
    public RetResult receiveITCompetitionApplication(@RequestBody MajorCompetitionDto majorCompetitionDto) {
//        int ret = stuApplicationService.insertITCompetition(majorCompetitionDto);
//        if (ret == 0)
//            return RetResponse.makeErrRsp("error");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "");
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
    * 奖学金申请接收——专业论文加分
    */
    @ApiOperation("奖学金申请接收——专业论文")
    @PostMapping("/student/receiveMajorThesisApplication")
    public RetResult receiveMajorThesisApplication(@RequestBody MajorThesisDto majorThesisDto) {
//        int ret = stuApplicationService.insertMajorThesis(majorThesisDto);
//        if (ret == 0)
//            return RetResponse.makeErrRsp("error");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "");
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
    * 奖学金申请接收——发明专利
    */
    @ApiOperation("奖学金申请接收——发明专利")
    @PostMapping("/student/receivePatentApplication")
    public RetResult receivePatentApplication(@RequestBody PatentDto patentDto) {
//        int ret = stuApplicationService.insertPatent(patentDto, 140);
//        if (ret == 0)
//            return RetResponse.makeErrRsp("error");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "");
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }


    /*
    * 奖学金申请撤销
    * 删除所有除CET成绩以外的获奖信息
    */
    @ApiOperation("奖学金申请撤销")
    @PostMapping("/student/revokeApplication")
    public RetResult revokeApplication(@RequestParam("userId") String userId) {
        int ret = stuApplicationService.deleteApplication(userId);
        if (ret <= 0)
            return RetResponse.makeRsp(RetCode.FAIL, "撤销学生申请失败");
        return RetResponse.makeRsp(RetCode.SUCCESS, "撤销学生申请成功");
    }

    /*
    * 奖学金申请信息获取——GPA获取
    */
    @ApiOperation("奖学金申请信息获取——GPA获取")
    @PostMapping("/student/getGPAApplication")
    public RetResult getGPAApplication(@RequestParam("userId") String userId) {
//        double ret = stuApplicationService.getGPA(userId);
//        return RetResponse.makeRsp(RetCode.SUCCESS, "成功获取GPA信息", ret);
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
     * 奖学金申请信息获取——外语成绩
     */
    @ApiOperation("奖学金申请信息获取——外语成绩")
    @PostMapping("/student/getForeignApplication")
    public RetResult getForeignApplication(@RequestParam("userId") String userId) {
//        ForeignExamDto ret = stuApplicationService.getForeignExam(userId);
//        if (ret == null)
//            return RetResponse.makeErrRsp("获取信息失败，可能是该userId对应信息不存在");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "成功获取外语成绩信息", ret);
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
     * 奖学金申请信息获取——专业证书
     */
    @ApiOperation("奖学金申请信息获取——专业证书")
    @PostMapping("/student/getMajorExamApplication")
    public RetResult getMajorExamApplication(@RequestParam("userId") String userId) {
//        MajorExamDto ret = stuApplicationService.getMajorExam(userId);
//        if (ret == null)
//            return RetResponse.makeErrRsp("获取信息失败，可能是该userId对应信息不存在");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "成功获取专业证书信息", ret);
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
     * 奖学金申请信息获取——专业竞赛加分和IT加分
     * 以后可考虑二者合并
     */
    @ApiOperation("奖学金申请信息获取——专业竞赛加分")
    @PostMapping("/student/getMajorCompetitionApplication")
    public RetResult getMajorCompetitionApplication(@RequestParam("userId") String userId) {
//        MajorCompetitionDto ret = stuApplicationService.getMajorCompetition(userId);
//        if (ret == null)
//            return RetResponse.makeErrRsp("获取信息失败，可能是该userId对应信息不存在");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "成功获取专业竞赛加分信息", ret);
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }
    @ApiOperation("奖学金申请信息获取——IT节加分")
    @PostMapping("/student/getITCompetitionApplication")
    public RetResult getITCompetitionApplication(@RequestParam("userId") String userId) {
//        MajorCompetitionDto ret = stuApplicationService.getITCompetition(userId);
//        if (ret == null)
//            return RetResponse.makeErrRsp("获取信息失败，可能是该userId对应信息不存在");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "成功获取IT节加分信息", ret);
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
     * 奖学金申请信息获取——专业论文加分
     */
    @ApiOperation("奖学金申请信息获取——专业论文")
    @PostMapping("/student/getMajorThesisApplication")
    public RetResult getMajorThesisApplication(@RequestParam("userId") String userId) {
//        MajorThesisDto ret = stuApplicationService.getMajorThesis(userId);
//        if (ret == null)
//            return RetResponse.makeErrRsp("获取信息失败，可能是该userId对应信息不存在");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "成功获取专业论文信息", ret);
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }

    /*
     * 奖学金申请信息获取——发明专利
     */
    @ApiOperation("奖学金申请信息获取——发明专利")
    @PostMapping("/student/getPatentApplication")
    public RetResult getPatentApplication(@RequestParam("userId") String userId) {
//        PatentDto ret = stuApplicationService.getPatent(userId);
//        if (ret == null)
//            return RetResponse.makeErrRsp("获取信息失败，可能是该userId对应信息不存在");
//        return RetResponse.makeRsp(RetCode.SUCCESS, "成功获取发明专利信息", ret);
        return RetResponse.makeRsp(RetCode.FAIL, "该接口已失效,到2.0端口找替代端口");
    }
}
